﻿<UserControl x:Class="SellAvi.Views.ControlProductUploader"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:converters="clr-namespace:SellAvi.Views.Converters"
             mc:Ignorable="d"
             DataContext="{Binding UploadProduct, Source={StaticResource Locator}}"
             >
    <UserControl.Resources>
        <converters:BooleanToVisibilityConverter x:Key="bvc" />
    </UserControl.Resources>

    <Grid Margin="10,5,10,5">
        <StackPanel Orientation="Vertical">
            <DockPanel Height="24" LastChildFill="True">
                <ToggleButton DockPanel.Dock="Left" x:Name="btnShowDetails" ToolTip="Подробная информация о публикуемом товаре">
                    <Image Source="/SellAvi;component/Resources/arrow3_n.png" Width="16"></Image>
                </ToggleButton>
                <Button DockPanel.Dock="Left" Command="{Binding ReUploadProductCommand}" ToolTip="Попытаться опубликовать заново" Visibility="{Binding CurrentTaskHasErrors, Mode=OneWay, FallbackValue=Hidden}">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/SellAvi;component/Resources/reload.png" Width="16"></Image>
                    </StackPanel>
                </Button>
                <Button DockPanel.Dock="Left" Command="{Binding ForceUploadCommand}" ToolTip="Загрузка всех товаров без уведомлений">
                    <Image Source="/SellAvi;component/Resources/next.png" Width="16"></Image>
                </Button>
                <Button DockPanel.Dock="Left" Command="{Binding UploadProductCommand}" ToolTip="Начать загрузку товаров на Avito">
                    <StackPanel Orientation="Horizontal">
                        <!--<Image Source="/SellAvi;component/Resources/play.png" Width="16"></Image>-->
                        <Image Width="16">
                            <Image.Style>
                                <Style TargetType="{x:Type Image}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding PublicationInProgress}" Value="False">
                                            <Setter Property="Source" Value="/SellAvi;component/Resources/play.png" />
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding PublicationInProgress}" Value="True">
                                            <Setter Property="Source" Value="/SellAvi;component/Resources/pause.png" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Image.Style>
                        </Image>
                        <TextBlock Margin ="5,0,5,0" TextAlignment="Center">
                            <TextBlock.Style>
                                <Style TargetType="{x:Type TextBlock}">
                                    <Setter Property="Text" Value="Старт задач"/>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding PublicationInProgress}" Value="True" >
                                            <Setter Property="Text" Value="Приостановить"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBlock.Style>
                        </TextBlock>
                    </StackPanel>
                </Button>
                <StackPanel Orientation="Horizontal" DockPanel.Dock="Right">
                    <Button Command="{Binding PrevProductCommand}" ToolTip="Перейти к предыдущей задаче" Width="20" Height="18">
                        <Image Source="/SellAvi;component/Resources/arrow2_n.png"></Image>
                    </Button>
                    <WrapPanel VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,5,0">
                        <TextBlock Text="{Binding CurrentProductNumber}" Padding="0" Width="20" TextAlignment="Center"></TextBlock>
                        <TextBlock Text="/" Padding="0" Width="10" TextAlignment="Center"></TextBlock>
                        <TextBlock Text="{Binding TotalProductsCount}" Padding="0" Width="20"  TextAlignment="Center"></TextBlock>
                    </WrapPanel>
                    <Button Command="{Binding NextProductCommand}" ToolTip="Перейти к следующей задаче" Width="20" Height="18">
                        <Image Source="/SellAvi;component/Resources/arrow2_s.png"></Image>
                    </Button>
                </StackPanel>
                <Grid>
                    <TextBlock Text="{Binding PublicationStatusMessage}" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                    <ProgressBar VerticalAlignment="Bottom"  Width="100" Margin="0,0,0,0" Value="{Binding PublicationProgress, Mode=OneWay}" Height="5" BorderThickness="0"/>
                </Grid>
            </DockPanel>

            <StackPanel Visibility="{Binding ElementName=btnShowDetails, Path=IsChecked, Converter={StaticResource bvc}}">
                <!--<StackPanel>-->
                <DockPanel LastChildFill="True" Height="60">
                    <StackPanel DockPanel.Dock="Left" VerticalAlignment="Center">

                        <!--<Button Command="{Binding UnMarkProductCommand}" ToolTip="Не публиковать товар" Width="20" Height="18">
                            <Image Source="/SellAvi;component/Resources/trash.png"></Image>
                        </Button>-->
                    </StackPanel>
                    <Border DockPanel.Dock="Right" Width="60" CornerRadius="2" BorderThickness="0" BorderBrush="#EEEEEE">
                        <Image Source="{Binding CurrentAvitoTask.AP.MainProductImage}" Stretch="UniformToFill" Margin="2"/>
                    </Border>
                    <TextBlock  DockPanel.Dock="Top" Text="{Binding CurrentAvitoTask.TaskStatus.OperationMessage}" Padding="2,0,0,0" FontSize="10" FontWeight="DemiBold"></TextBlock>
                    <TextBlock  TextWrapping="Wrap" Text="{Binding CurrentAvitoTask.TaskCompletedUrl}" Padding="2,0,0,0" FontSize="10"></TextBlock>
                </DockPanel>
            </StackPanel>



        </StackPanel>
    </Grid>
</UserControl>
